using System;
using System.Runtime.InteropServices;
using NovaCore.Interop.SafeHandles;

namespace NovaCore.Interop {
	public delegate void NvtlSdkEventFunc(IntPtr user_data, int type, int size, IntPtr ev);

	public static class Core {
		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern CoreHandle NvtlCommon_CreateSession();

		[DllImport(NvtlConstants.LIB_CORE)]
		internal static extern void NvtlCommon_ReleaseSession(IntPtr session);

		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_GetAvailableDevices(CoreHandle session, [Out] DeviceDetail[] pDev_list, ref long dev_list_size);

		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_AttachDevice(CoreHandle session, ref DeviceDetail pAttachInfo);

		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_DetachDevice(CoreHandle session);

		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_AutoInstallEnabled(CoreHandle session, PropertyAction bSet, ref bool bEnabled);

		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_GetBatteryState(CoreHandle session, out BATTERY_STATE state, out short chargePct);

		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_GetDataCounters(CoreHandle session, out long dataTx, out long dataRx);

		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_GetDeviceInfo(CoreHandle session, out DeviceInfoStruct pDevInfo);

		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_GetTemperature(CoreHandle session, out short temp);

		/* [DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_RegisterEventCallback(CoreSafeHandle session, NvtlEventCallback callback);

		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_UnregisterEventCallback(CoreSafeHandle session, NvtlEventCallback callback); */

		[DllImport(NvtlConstants.LIB_CORE)]
		public static extern NvtlErrorCode NvtlCommon_GetSdkVersion(byte[] buffer, short buffer_len);
	}
}